// 面试题 01.05. 一次编辑

public class StrOp{
    public static void main(String[] args) {
        Solution s = new Solution();
        String first = "islander";
        String second = "slander";
        boolean ans = s.oneEditAway(first, second);
        System.out.println(ans);
    }
}


class Solution {
    public boolean oneEditAway(String first, String second) {
        if(first.equals(second))return true;
        else if(first.length()==second.length()){
            int times = 0;
            for(int i=0;i<first.length();i++){
                if(first.charAt(i)!=second.charAt(i)) {
                    times++;
                    if(times>1)return false;
                }
            }
            return true;
        }else if(Math.abs(first.length()-second.length())==1){
            String a ="";
            String b ="";
            if(first.length()>second.length()){
                a = first;
                b = second;
            }else{
                a = second;
                b = first;
            }
            int index = -1;
            for(int i=0;i<b.length();i++){
                if(a.charAt(i)!=b.charAt(i)) {
                    index = i;
                    break;
                }
            }
            if(index==-1) return true;
            String c = a.substring(0,index)+a.substring(index+1);
            return c.equals(b);

        }
        return false;
    }
}